<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;

class Operation
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(env('LOG_IS_OPERATION',false)){

            $userId = $request->session()->get('adminUserId');
            $params = $request->input();
            $ip = $request->ip();
            $url = $request->url();
            Log::channel('operation')->info($userId,compact('userId','params','url','ip'));
        }



        return $next($request);
    }
}
